<?php

error_reporting(E_ALL);

/**
 * AplicacionWeb - class.Salida.php
 *
 * $Id$
 *
 * This file is part of AplicacionWeb.
 *
 * Automatically generated on 30.11.2011, 09:28:55 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * include DetalleSalida
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.DetalleSalida.php');

/**
 * include ModeloSalida
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.ModeloSalida.php');

/* user defined includes */
// section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021BF-includes begin
// section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021BF-includes end

/* user defined constants */
// section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021BF-constants begin
// section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021BF-constants end

/**
 * Short description of class Salida
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class Salida
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    /**
     * Short description of attribute detSalida : DetalleSalida
     *
     * @access public
     */
    public $detSalida = null;

    /**
     * Short description of attribute modSalida : ModeloSalida
     *
     * @access public
     */
    public $modSalida = null;

    /**
     * Short description of attribute row : Array
     *
     * @access public
     */
    public $row = null;

    // --- OPERATIONS ---

    /**
     * Short description of method Salida
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Salida()
    {
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021C9 begin
        $this->modSalida = new ModeloSalida();        
        //$this->detVenta = new DetalleVenta();
        $this->row["folio"] = $this->modSalida->getNextFolio(); 
		//echo $this->row["folio"];
		//$this->row["empleado"] = "Algo";
        $this->row["fecha"] = date("Y-m-d");
        $this->isOnSesion();
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021C9 end
    }

    /**
     * Short description of method Marcar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  cveart
     * @param  cant
     * @return mixed
     */
    public function Marcar($cveart, $cant)
    {
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021CB begin
        $newDetail = new DetalleSalida($cveart, $cant);
        $this->detSalida[] = $newDetail;					// add det Venta
		
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021CB end
    }

    /**
     * Short description of method Procesar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Procesar()
    {
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021CF begin
    	$this->row["emp"] = $_REQUEST["emp"];
		$this->modSalida->insertRow($this->row);  // inserta maestro
		$last = $this->modSalida->lastRow();
		//echo "Ultimo: " . $last;
		//$this->row["ultimo"] = $last;
		//var_dump($this->row["folio"]);
		
		for ($i=0; $i<count($this->detSalida); $i++){        
        		$this->detSalida[$i]->salvar($this->row["folio"],$last);
        }
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021CF end
    }

    /**
     * Short description of method Cancelar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Cancelar()
    {
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D1 begin
        $_SESSION["Salida"] = "";
        unset($_SESSION["Salida"]);
		echo "<script language='javascript'>location.href='indexMDsalida.php'</script>";
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D1 end
    }

    /**
     * Short description of method setSesion
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function setSesion()
    {
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D3 begin
        $_SESSION['Salida'] = $this;
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D3 end
    }

    /**
     * Short description of method isOnSesion
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function isOnSesion()
    {
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D5 begin
    	if (@$_SESSION['Salida']) {
    	 	return true;
    	 } else {
    	 	return false;
    	 }
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D5 end
    }

    /**
     * Short description of method getSesion
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function getSesion()
    {
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D7 begin
        return $_SESSION['Salida'];
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D7 end
    }

    /**
     * Short description of method Quitar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  cveart
     * @return mixed
     */
    public function Quitar($cveart)
    {
        // section -64--88-3-62-368c33cf:133f5022296:-8000:0000000000001284 begin
		unset($this->detSalida[$cveart]);
		echo "<script language='javascript'>location.href='indexMDsalida.php'</script>";
        // section -64--88-3-62-368c33cf:133f5022296:-8000:0000000000001284 end
    }

} /* end of class Salida */

?>